var viewport;
var tab;
var Tree = Ext.tree;
   var selNode = null;

//设置树的点击事件 
function treeClick(node,e) { 
 //alert(node.id);
	 if(!node.isLeaf()){
		e.stopEvent();
		var n = tab.getComponent(node.id);
		var c_1 = 'app/listNews.action';
		var c_2 = 'app/listProduct.action';
		var c_3 = 'app/listCase.action';
		var c_4 = 'app/listMessage.action';
		var c_5 = 'app/listSolvtion.action';
		var c_6 = 'app/listFile.action';
		var url='';
		if(node.id == 'c_1'){
		   url = c_1;
		}
		if(node.id == 'c_2'){
		   url = c_2;
		}
		if(node.id == 'c_3'){
		   url = c_3;
		}
		if(node.id == 'c_4'){
		   url = c_4;
		}
		if(node.id == 'c_5'){
		   url = c_5;
		}
		if(node.id == 'c_6'){
		   url = c_6;
		}
		if (!n) {
			var n = tab.add({
				'id' : node.id,
				'title' : node.text,
				 closable:true,
				 html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="' + url + '"></iframe>'

				});
		}
		tab.setActiveTab(n);
	 }
}
 

//生成标签页
tab = new Ext.TabPanel({
			region:'center',
			resizeTabs:true, // turn on tab resizing
        minTabWidth: 115,
        tabWidth:135,
        enableTabScroll:true,
        width:600,
        height:250,
        defaults: {autoScroll:true}
		});
		
		 
        
Ext.onReady(function(){
   //layout
    viewport = new Ext.Viewport({
		layout:'border',
		items:[
			new Ext.BoxComponent({
				region:'north',
				el: 'north',
				height:80
			}),new Ext.BoxComponent({
				region:'south',
				el: 'south',
				height:25
			}),{
			region:'west',
			id:'west-panel',
			split:true,
			width: 200,
			minSize: 0,
			maxSize: 400,
			margins:'0 0 0 0',
			layout:'accordion',
			title:'奥启应用开发平台',
			collapsible :true,
			layoutConfig:{
				animate:true
				},
		    items: [
			    {
					title:'<b>新闻发布</b>',
					border:false,
					html:'<div id="tree-div1" style="overflow:auto;width:100%;height:100%"></div>'
					//iconCls:'nav'
			    },{
					title:'<b>产品方案</b>',
					border:false,
					//iconCls:'settings',
					html:'<div id="tree-div2" style="overflow:auto;width:100%;height:100%"></div>'
			    },{
					title:'<b>成功案例</b>',
					border:false,
					//iconCls:'settings',
					html:'<div id="tree-div3" style="overflow:auto;width:100%;height:100%"></div>'
			    },{
					title:'<b>留言管理</b>',
					border:false,
					//iconCls:'settings',
					html:'<div id="tree-div4" style="overflow:auto;width:100%;height:100%"></div>'
			    },{
					title:'<b>系统管理</b>',
					border:false,
					//iconCls:'settings',
					html:'<div id="tree-div5" style="overflow:auto;width:100%;height:100%"></div>'
			    },{
					title:'<b>个人设置</b>',
					border:false,
					//iconCls:'settings',
					html:'<div id="tree-div6" style="overflow:auto;width:100%;height:100%"></div>'
			    }]
			},
	        tab//初始标签页
		 ]
	});


	//设置树形面板
	var Tree = Ext.tree;
	// set the root node
	var root = new Tree.AsyncTreeNode({
		text: 'Ext JS',
		draggable:false,
		id:'1'
	});

	var tree = new Tree.TreePanel({
		el:'tree-div1',
		autoScroll:true,
		root:root,
		animate:true,
		enableDD:false,
		border:false,
		rootVisible:false,
		containerScroll: true,
		loader: new Tree.TreeLoader({
			dataUrl:'pre/indexTree.do?action=index',
            baseParams:{menuId:1}
		})
	});
	//页面打开时加载
    tree.on("beforeload", function(treeLoader, node) {
	 	tree.loader.baseParams.menuId = treeLoader.id;
    	}, this);
    tree.setRootNode(root);
	// render the tree
	tree.render();
	root.appendChild(root_1);
	root.appendChild(root_6);
	root.expand();
	tree.on('click',treeClick);


////////////////////////////////////////////////////////////////////
// set the root node
	var root2 = new Tree.AsyncTreeNode({
		text: 'Ext JS',
		draggable:false,
		id:'2'
	});
   var tree2 = new Tree.TreePanel({
		el:'tree-div2',
		autoScroll:true,
		root:root2,
		animate:true,
		enableDD:false,
		border:false,
		rootVisible:false,
		containerScroll: true,
		loader: new Tree.TreeLoader({
			dataUrl:'pre/indexTree.do?action=index',
            baseParams:{menuId:2}
		})
	});
	//页面打开时加载
    tree2.on("beforeload", function(treeLoader, node) {
	 	tree2.loader.baseParams.menuId = treeLoader.id;
    	}, this);
    tree2.setRootNode(root2);
	// render the tree
	tree2.render();
	root2.expand();
	tree2.on('click',treeClick);
	root2.appendChild(root_2);
	root2.appendChild(root_5);
/////////////////////////////////////////////////////////
var root3 = new Tree.AsyncTreeNode({
		text: 'Ext JS',
		draggable:false,
		id:'3'
	});
   var tree3 = new Tree.TreePanel({
		el:'tree-div3',
		autoScroll:true,
		root:root3,
		animate:true,
		enableDD:false,
		border:false,
		rootVisible:false,
		containerScroll: true,
		loader: new Tree.TreeLoader({
			dataUrl:'pre/indexTree.do?action=index',
            baseParams:{menuId:3}
		})
	});
	//页面打开时加载
    tree3.on("beforeload", function(treeLoader, node) {
	 	tree3.loader.baseParams.menuId = treeLoader.id;
    	}, this);
    tree3.setRootNode(root3);
	// render the tree
	tree3.render();
	root3.expand();
	tree3.on('click',treeClick);
	root3.appendChild(root_3);
//////////////////////////////////////////////
var root4 = new Tree.AsyncTreeNode({
		text: 'Ext JS',
		draggable:false,
		id:'4'
	});
   var tree4 = new Tree.TreePanel({
		el:'tree-div4',
		autoScroll:true,
		root:root4,
		animate:true,
		enableDD:false,
		border:false,
		rootVisible:false,
		containerScroll: true,
		loader: new Tree.TreeLoader({
			dataUrl:'pre/indexTree.do?action=index',
            baseParams:{menuId:4}
		})
	});
	//页面打开时加载
    tree4.on("beforeload", function(treeLoader, node) {
	 	tree4.loader.baseParams.menuId = treeLoader.id;
    	}, this);
    tree4.setRootNode(root4);
	// render the tree
	tree4.render();
	root4.expand();
	tree4.on('click',treeClick);
	root4.appendChild(root_4);
	/////////////////////////////////////
	var root5 = new Tree.AsyncTreeNode({
		text: 'Ext JS',
		draggable:false,
		id:'5'
	});
   var tree5 = new Tree.TreePanel({
		el:'tree-div5',
		autoScroll:true,
		root:root5,
		animate:true,
		enableDD:false,
		border:false,
		rootVisible:false,
		containerScroll: true,
		loader: new Tree.TreeLoader({
			dataUrl:'pre/indexTree.do?action=index',
            baseParams:{menuId:5}
		})
	});
	//页面打开时加载
    tree5.on("beforeload", function(treeLoader, node) {
	 	tree5.loader.baseParams.menuId = treeLoader.id;
    	}, this);
    tree5.setRootNode(root5);
	// render the tree
	tree5.render();
	root5.expand();
	tree5.on('click',treeClick);
	//////////////////////////////
	var root6 = new Tree.AsyncTreeNode({
		text: 'Ext JS',
		draggable:false,
		id:'6'
	});
   var tree6 = new Tree.TreePanel({
		el:'tree-div6',
		autoScroll:true,
		root:root6,
		animate:true,
		enableDD:false,
		border:false,
		rootVisible:false,
		containerScroll: true,
		loader: new Tree.TreeLoader({
			dataUrl:'pre/indexTree.do?action=index',
            baseParams:{menuId:6}
		})
	});
	//页面打开时加载
    tree6.on("beforeload", function(treeLoader, node) {
	 	tree6.loader.baseParams.menuId = treeLoader.id;
    	}, this);
    tree6.setRootNode(root6);
	// render the tree
	tree6.render();
	root6.expand();
	tree6.on('click',treeClick);
	//end loding
	setTimeout(
				function() {
					Ext.get('loading').remove();
					Ext.get('loading-mask').fadeOut({remove:true});
				}, 250
			  );
});
////////////////////////////////////////////////////

 var root_1=new Ext.tree.TreeNode({
		id:'c_1',
		icon:'../module/images/dian.gif',
		text:'<b>  新闻管理</b>'
	});
var root_2=new Ext.tree.TreeNode({
		id:'c_2',
		icon:'../module/images/dian.gif',
		text:'  产品管理'
	});
var root_3=new Ext.tree.TreeNode({
		id:'c_3',
		icon:'../module/images/dian.gif',
		text:'  案例管理'
	});
var root_4=new Ext.tree.TreeNode({
		id:'c_4',
		icon:'../module/images/dian.gif',
		text:'  留言管理'
	});
var root_5=new Ext.tree.TreeNode({
		id:'c_5',
		icon:'../module/images/dian.gif',
		text:'  解决方案'
	});
var root_6=new Ext.tree.TreeNode({
		id:'c_6',
		icon:'../module/images/dian.gif',
		text:'  <b>文件管理</b>'
	});